import request from '@/utils/request'


// GET

// 获取当前区域设备状态
export function getDeviceStatus(regionId) {
    return request({
        url: '/device/door/assemblyDesDataWeb',
        method: 'get',
        params: { regionId }
    })
}


// 获取echarts数据
export function getEchartsData(regionId) {
    return request({
        url: '/device/door/assemblyDesDataWeb',
        method: 'get',
        params: { regionId }
    })
}

//获取区域控件
export function getAreaControl(regionId) {
    return request({
        url: '/device/function/list',
        method: 'get',
        params: { regionId }
    })
}


//全开/全关 （门）
export function allOnOff(type,regionId,funId) {
    return request({
        url: '/server/doorControl/fullOpenClose',
        method: 'get',
        params: { type,regionId,funId }
    })
}

// 获取数据接口
export function information() {
    return request({
        url: '/hard/device/showSomeMessageToWeb',
        method: 'get',
        // headers:'Bearer 91314dbd-4ddd-4c9b-88af-627e2d717498',
        headers: {
            'Authorization': 'Bearer 91314dbd-4ddd-4c9b-88af-627e2d717498',
            'Content-Type': 'application/json;charset=utf-8'
        },
        params: {}
    })
}


// POST
//控制门的开关 doorControl
export function doorControl(doorId,highLowSpeed,openCloseDoor) {
    return request({
        url: '/server/doorControl',
        method: 'post',
        data: { doorId,highLowSpeed,openCloseDoor}
    })
}
//控制门的开关 doorControl
export function doorControls(doorId) {
    return request({
        url: '/server/doorControl',
        method: 'post',
        data: { doorId,highLowSpeed:0,openCloseDoor:1}
    })
}

//PUT 

//上锁 
export function lock(doorId,type) {
    return request({
        url: '/device/door/lockOrUnLock',
        method: 'put',
        data: { doorId,type}
    })
}

//DEL 
export function clearExe(doorId) {
    return request({
        url: '/server/doorControl/clearExe/'+ doorId,
        method: 'delete',
    })
}